﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace IllusionUtility.GetUtility
{
	// Token: 0x020003E8 RID: 1000
	public static class TransformFindEx
	{
		// Token: 0x060018F2 RID: 6386 RVA: 0x000A1DEC File Offset: 0x0009FFEC
		public static GameObject FindLoop(this Transform transform, string name)
		{
			if (string.Compare(name, transform.gameObject.name) == 0)
			{
				return transform.gameObject;
			}
			for (int i = 0; i < transform.childCount; i++)
			{
				GameObject gameObject = transform.GetChild(i).FindLoop(name);
				if (null != gameObject)
				{
					return gameObject;
				}
			}
			return null;
		}

		// Token: 0x060018F3 RID: 6387 RVA: 0x000A1E4C File Offset: 0x000A004C
		public static void FindLoopPrefix(this Transform transform, List<GameObject> list, string name)
		{
			if (string.Compare(name, 0, transform.gameObject.name, 0, name.Length) == 0)
			{
				list.Add(transform.gameObject);
			}
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					object obj = enumerator.Current;
					Transform transform2 = (Transform)obj;
					transform2.FindLoopPrefix(list, name);
				}
			}
			finally
			{
				IDisposable disposable;
				if ((disposable = (enumerator as IDisposable)) != null)
				{
					disposable.Dispose();
				}
			}
		}

		// Token: 0x060018F4 RID: 6388 RVA: 0x000A1ED8 File Offset: 0x000A00D8
		public static void FindLoopTag(this Transform transform, List<GameObject> list, string tag)
		{
			if (transform.gameObject.CompareTag(tag))
			{
				list.Add(transform.gameObject);
			}
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					object obj = enumerator.Current;
					Transform transform2 = (Transform)obj;
					transform2.FindLoopTag(list, tag);
				}
			}
			finally
			{
				IDisposable disposable;
				if ((disposable = (enumerator as IDisposable)) != null)
				{
					disposable.Dispose();
				}
			}
		}

		// Token: 0x060018F5 RID: 6389 RVA: 0x000A1F58 File Offset: 0x000A0158
		public static void FindLoopAll(this Transform transform, List<GameObject> list)
		{
			list.Add(transform.gameObject);
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					object obj = enumerator.Current;
					Transform transform2 = (Transform)obj;
					transform2.FindLoopAll(list);
				}
			}
			finally
			{
				IDisposable disposable;
				if ((disposable = (enumerator as IDisposable)) != null)
				{
					disposable.Dispose();
				}
			}
		}

		// Token: 0x060018F6 RID: 6390 RVA: 0x000A1FC4 File Offset: 0x000A01C4
		public static GameObject FindTop(this Transform transform)
		{
			return (!(null == transform.parent)) ? transform.parent.FindTop() : transform.gameObject;
		}

		// Token: 0x060018F7 RID: 6391 RVA: 0x000A1FF0 File Offset: 0x000A01F0
		public static GameObject[] FindRootObject(this Transform transform)
		{
			return Array.FindAll<GameObject>(UnityEngine.Object.FindObjectsOfType<GameObject>(), (GameObject item) => item.transform.parent == null);
		}
	}
}
